package 反射;

import java.awt.List;
import java.lang.reflect.Array;

//Java Class.isPrimitive()判断是否是基本类型的字节码
//Class.isPrimitive()判定指定的Class对象是否表示一个Java的基类型（boolean、char、byte、short、int、long、float、double）。

//定义
//public boolean isPrimitive()
//返回值：此方法返回true，当且仅当这个类表示一个基本类型。
//
//例子
//判断是否是基本类型的字节码
/*public class 使用isPrimitive {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		String str = "abc";
		Class cls1 = str.getClass();
		Class cls2 = String.class;
		Class cls3 = null;// 必须要加上null
		try {
			cls3 = Class.forName("java.lang.String");
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println(cls1 == cls2);//true
		System.out.println(cls1 == cls3);//true

		System.out.println("1"+cls1.isPrimitive());//false String非基本类型
		System.out.println("2"+int.class.isPrimitive());//true  int为基本类型 判定指定的 Class 对象是否表示一个基本类型。
		System.out.println(int.class == Integer.class);//false
		System.out.println(int.class == Integer.TYPE);//true
		System.out.println("5"+int[].class.isPrimitive());//false
		System.out.println("6"+int[].class.isArray());//true
	}
}*/

//java原始类型判断
public class 使用isPrimitive {
	public static void main(String[] args) {
		Class<?> stringClass = String.class;
		System.out.println("String is primitive type：" + stringClass.isPrimitive());//false

		Class<Boolean> booleanClass = Boolean.class;
		System.out.println("Boolean is primitive type：" + booleanClass.isPrimitive());//false

		Class booleanType = boolean.class;
		System.out.println("boolean is primitive type：" + booleanType.isPrimitive());//true

		Class byteType = byte.class;
		System.out.println("byte is primitive type：" + byteType.isPrimitive());//true

		Class charType = char.class;
		System.out.println("char is primitive type：" + charType.isPrimitive());//true

		Class shortType = short.class;
		System.out.println("short is primitive type：" + shortType.isPrimitive());//true

		Class intType = int.class;
		System.out.println("int is primitive type：" + intType.isPrimitive());//true

		Class longType = long.class;
		System.out.println("long is primitive type：" + longType.isPrimitive());//true

		Class floatType = float.class;
		System.out.println("float is primitive type：" + floatType.isPrimitive());//true

		Class doubleType = double.class;
		System.out.println("double is primitive type：" + doubleType.isPrimitive());//true
		
		Class arrayType=Array.class;
		System.out.println("array is primitive type：" + arrayType.isPrimitive());//false
		
		Class listType=List.class;
		System.out.println("list is primitive type：" + listType.isPrimitive());//false
		
	}
}
//执行结果：
//
//String is primitive type：false
//Boolean is primitive type：false
//boolean is primitive type：true
//byte is primitive type：true
//char is primitive type：true
//short is primitive type：true
//int is primitive type：true
//long is primitive type：true
//float is primitive type：true
//double is primitive type：true